package cn.hs.service.impl;

import cn.hs.entity.Free;
import cn.hs.mapper.FreeMapper;
import cn.hs.service.FreeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName FreeServiceImpl
 * @Description TODO
 * @Author mujiale
 * @Date 2024年10月24日 10:09
 * @Version 1.0
 */
@Service
public class FreeServiceImpl implements FreeService {
    @Autowired
    private FreeMapper freeMapper;
    @Override
    public PageInfo<Free> selectAll(Integer pageNum, Integer pageSize, Free free) {
        PageHelper.startPage(pageNum,pageSize);
        List<Free> frees = freeMapper.selectAll(free);
        PageInfo pageInfo = new PageInfo(frees);
        return pageInfo;
    }

    @Override
    public int insert(Free free) {
        return freeMapper.insert(free);
    }

    @Override
    public int update(Free free) {
        return freeMapper.update(free);
    }

    @Override
    public int delete(Integer id) {
        return freeMapper.delete(id);
    }

    @Override
    public List<Free> select(Free free) {
        return freeMapper.selectAll(free);
    }

    @Override
    public Free selectById(Long id)
    {
        Free free = freeMapper.selectById(Math.toIntExact(id));
        return free;

    }
}
